import axiosInstance from "./axios";
import { RequestHttpEnum, ContentTypeEnum } from "../enums/httpEnum";

export const get = (url: string, params?: object) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.GET,
    params: params,
  });
};

export const post = (url: string, data?: object, headersType?: string) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.POST,
    data: data,
    headers: {
      "Content-Type": headersType || ContentTypeEnum.JSON,
    },
  });
};

export const patch = (url: string, data?: object, headersType?: string) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.PATCH,
    data: data,
    headers: {
      "Content-Type": headersType || ContentTypeEnum.JSON,
    },
  });
};

export const put = (
  url: string,
  data?: object,
  headersType?: ContentTypeEnum,
) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.PUT,
    data: data,
    headers: {
      "Content-Type": headersType || ContentTypeEnum.JSON,
    },
  });
};

export const del = (url: string, params?: object) => {
  return axiosInstance({
    url: url,
    method: RequestHttpEnum.DELETE,
    params,
  });
};
